﻿using UnityEngine;
using System.Collections;

namespace Room
{
    public class RCAIUnionActorDeath : RCAIUnionActorBase
    {
        GameObject obj;
        GameObject lit;
        protected override void OnEnter()
        {
            if(obj==null)
            {
                obj = controller.Spawn(RoomUnionFight.DIE);
                obj.transform.localPosition = new Vector3(0, 2, 0);
                obj.SetActive(true);
            }
            else
            {
                obj.SetActive(true);
            }

            if(lit==null)
            {
                lit = controller.Spawn(RoomUnionFight.LIGHT);
            }
            else
            {
                lit.SetActive(true);
            }

            controller.owner.SetInView(false);
            if (controller.owner.name == StaticData.playerData.playerId.ToString())
            {
                EasyTouchTool.Instance.Hide();
            }
            controller.ShowHp(false);
        }

        protected override void OnTick()
        {
            controller.owner.move.StopMove();
        }

        protected override void OnLeave()
        {
            controller.Unspawn(obj);
            obj = null;
            controller.Unspawn(lit);
            lit = null;
            if (controller.owner.name == StaticData.playerData.playerId.ToString())
            {
                EasyTouchTool.Instance.ShowJoystick();
            }
            controller.ShowHp(true);
        }


    }
}